package com.nx.samuel.notify_demo.consumer;


import com.nx.samuel.notify_demo.api.HelloService;
import com.nx.samuel.notify_demo.consumer.impl.NotifyServiceImpl;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class NotifyConsumer {

    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("dubbo-consumer.xml");
        context.start();

        HelloService helloService = context.getBean("helloService", HelloService.class);
        NotifyServiceImpl notifyService = context.getBean("notifyServiceImpl", NotifyServiceImpl.class);

        int id = 1;
        String result = helloService.hello(id);
        System.out.println("result is" + result);
        for (int i = 0; i < 10; i++) {
            if (!notifyService.retMap.containsKey(id)) {
                Thread.sleep(200);
            } else {
                break;
            }
        }

        System.out.println("result: " + notifyService.retMap.get(id));
    }
}
